package richbar.com.richbar.view.dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.view.View;
import android.widget.TextView;

import richbar.com.richbar.R;
import richbar.com.richbar.bean.VersionResult;

/**
 * Created by QiYang on 2018/12/5.
 */

public class VersionDialog {
    public static void show(Activity mActivity, VersionResult result,final OnRightListener listener) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
        View view = View.inflate(mActivity, R.layout.dialog_version, null);
        builder.setView(view);
        builder.setCancelable(false);
        TextView content = view.findViewById(R.id.content_tv);
        TextView time = view.findViewById(R.id.time_tv);
        TextView left = view.findViewById(R.id.left_tv);
        TextView right = view.findViewById(R.id.right_tv);
        content.setText(result.getData().getInfo().getContent());
        time.setText(result.getData().getInfo().getTime());
        final AlertDialog dialog = builder.create();
        left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });
        right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onBesure();
                dialog.cancel();
            }
        });
        dialog.show();
    }

    public interface OnRightListener {
        void onBesure();
    }
}
